/**
 * Copyright (c) 2006 RiseSoft Co.,Ltd  
 * $Header$
 */
package net.risesoft.risebi.collection.web;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import net.risesoft.risebi.collection.formula.runtime.Calculator;
import net.risesoft.risebi.collection.groovy.Fault;
import net.risesoft.risebi.collection.model.Application;
import net.risesoft.risebi.collection.model.Catalog;
import net.risesoft.risebi.collection.model.Formula;
import net.risesoft.risebi.collection.model.RangeObj;
import net.risesoft.risebi.collection.model.ReportData;
import net.risesoft.risebi.collection.model.ReportInstance;
import net.risesoft.risebi.collection.model.ReportInstanceFile;
import net.risesoft.risebi.collection.model.Service;
import net.risesoft.risebi.collection.model.SoInstance;
import net.risesoft.risebi.collection.model.Template;
import net.risesoft.risebi.collection.model.TemplateIndication;
import net.risesoft.risebi.collection.model.User;
import net.risesoft.risebi.collection.service.ApplicationManager;
import net.risesoft.risebi.collection.service.CatalogManager;
import net.risesoft.risebi.collection.service.DataOperationManager;
import net.risesoft.risebi.collection.service.ReportInstanceFileManager;
import net.risesoft.risebi.collection.service.ReportInstanceManager;
import net.risesoft.risebi.commons.struts2extension.Trimable;
import net.risesoft.risebi.commons.util.ExceptionUtil;
import net.risesoft.risebi.commons.util.GUID;
import net.risesoft.risebi.commons.util.JSONUtil;
import net.sf.json.JSONObject;

import org.apache.commons.beanutils.LazyDynaBean;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.commons.codec.net.URLCodec;

import com.opensymphony.xwork2.ActionInvocation;

/**
 * 
 * @author <a href="mailto: chenjian@risesoft.net">陈健</a>
 * @version $Revision$
 * 
 */
public class BaseDataOperationAction extends BaseAction implements Trimable {
    private static final long serialVersionUID = -1053582194103416065L;
    private final Log log = LogFactory.getLog(BaseDataOperationAction.class);

    private DataOperationManager dataOperationManager;
    private Calculator calculator;
    private ReportInstanceManager reportInstanceManager;
    private ReportInstanceFileManager reportInstanceFileManager;
    private CatalogManager catalogManager;
    private ApplicationManager applicationManager;

    private List<Fault> containedFaults;
    private ReportInstance ri;
    private ReportData rd;
    private String templateGuid;
    private SoInstance soi;
    private Application selectedTask;
    private List<SoInstance> userSois;
    private Catalog so;
    private List<Catalog> sos;
    private Service service;
    private String type; // 1：普通报表 2：基本情况表
    private String clientJsValidationError;

    // 以下三个字段用于文件上载
    private File[] myUpload;
    private String[] myUploadFileName;
    private String[] myUploadContentType;

    // 以下七个字段用于文件下载
    private InputStream fileStream;
    private String contentType;
    private String contentDisposition;
    private String contentCharSet;
    private int bufferSize = 4096;
    private int contentLength;
    private boolean allowCaching = false;

    //@Action(value = "prepareAdd", results = { @Result(name = "success", location = "/client/datapage/dataAdd.jsp"), @Result(name = "prepareEdit", location = "/client/datapage/dataEdit.jsp") })
    public String prepareAdd() throws Exception {
        method = "add";
        type = "1"; // 1表示普通报表，2表示基本情况表

        User user = this.getSessionUser();

        ri = (ReportInstance) reportInstanceManager.getObject(ReportInstance.class, ri.getGuid());
        templateGuid = ri.getTemplate().getGuid();
        service = ri.getService();
        selectedTask = ri.getApplication();

        if (rd == null) {
            rd = new ReportData();
            Map<String, String> indis = new HashMap<String, String>();
            Map<String, RangeObj> ranges = new HashMap<String, RangeObj>();
            rd.setRanges(ranges);
            rd.setIndis(indis);
        }

        // 假如已经填报或者有审核错误，就转到 prepareEdit
        if (ri.getStatus() != null && ri.getStatus() != ReportInstance.STATUS_NO) {
            method = "edit";
            calculator.doCalculate(templateGuid, rd, Formula.EXECUTEPOINT_EDIT, user, ri);
            return PREPAREEDIT;
        }

        calculator.doCalculate(templateGuid, rd, Formula.EXECUTEPOINT_ADD, user, ri);
        return SUCCESS;
    }

    //@Action(value = "prepareEdit", results = { @Result(name = "success", location = "/client/datapage/dataEdit.jsp"), @Result(name = "prepareAdd", location = "/client/datapage/dataAdd.jsp") })
    public String prepareEdit() throws Exception {
        method = "edit";
        type = "1"; // 1表示普通报表，2表示基本情况表

        User user = this.getSessionUser();

        ri = (ReportInstance) reportInstanceManager.getObject(ReportInstance.class, ri.getGuid());
        if (ri.getLockStatus() == 1) {
            throw new Exception("该报表已经被锁定，不能再被填报");
        }

        templateGuid = ri.getTemplate().getGuid();
        service = ri.getService();
        selectedTask = ri.getApplication();

        rd = dataOperationManager.getReportData(ri, templateGuid);

        // 假如填报状态为null或者为0，就转到 prepareAdd
        if (ri.getStatus() == null || ri.getStatus() == ReportInstance.STATUS_NO) {
            method = "add";
            calculator.doCalculate(templateGuid, rd, Formula.EXECUTEPOINT_ADD, user, ri);
            return PREPAREADD;
        }

        calculator.doCalculate(templateGuid, rd, Formula.EXECUTEPOINT_EDIT, user, ri);
        return SUCCESS;
    }

    //@Action(value = "saveData")
    public String saveData() throws Exception {
        Map map = new HashMap();

        try {
            User user = this.getSessionUser();
            ri = (ReportInstance) reportInstanceManager.getObject(ReportInstance.class, ri.getGuid());
            Map returnedMap = dataOperationManager.addReportData(clientJsValidationError, ri, rd, templateGuid, user);
            containedFaults = (List<Fault>) returnedMap.get("containedFaults");
            if (containedFaults == null || containedFaults.isEmpty()) {
                map.put("success", true);
                map.put("reason", "保存成功！");
                map.put("containedFaults", "[]");
            } else {
                map.put("success", false);
                map.put("reason", "保存成功，但出现校验或审核错误！");
                map.put("containedFaults", containedFaults);
            }
        } catch (Exception e) {
            log.error(ExceptionUtil.transformException(e));

            map.put("success", false);
            map.put("reason", "保存时程序出现异常！\r" + e.getMessage());
            map.put("containedFaults", "[]");
        }

        this.json = JSONObject.fromObject(map).toString();
        return AJAX;
    }

    @Action(value = "saveData2")
    public String saveData2() throws Exception {
        Map map = new HashMap();

        try {
            dataOperationManager.addReportData2(this.node);
            map.put("success", true);
            map.put("reason", "保存成功！");
        } catch (Exception e) {
            e.printStackTrace();
            map.put("success", false);
            map.put("reason", "保存时程序出现异常！\r" + e.getMessage());
        }

        this.json = JSONObject.fromObject(map).toString();
        return AJAX;
    }

    @Action(value = "saveDataBaseInfo")
    public String saveDataBaseInfo() throws Exception {
        Map map = new HashMap();

        try {
            User user = this.getSessionUser();
            Map returnedMap = dataOperationManager.addBaseInfoData(so, rd, templateGuid, user);
            containedFaults = (List<Fault>) returnedMap.get("containedFaults");
            if (containedFaults == null || containedFaults.isEmpty()) {
                map.put("success", true);
                map.put("reason", "保存成功！");
                map.put("containedFaults", "[]");
            } else {
                map.put("success", false);
                map.put("reason", "保存成功，但出现校验或审核错误！");
                map.put("containedFaults", containedFaults);
            }
        } catch (Exception e) {
            log.error(ExceptionUtil.transformException(e));

            map.put("success", false);
            map.put("reason", "保存时程序出现异常！\r" + e.getMessage());
            map.put("containedFaults", "[]");
        }

        this.json = JSONObject.fromObject(map).toString();
        return AJAX;
    }

    @SuppressWarnings("unchecked")
    @Action(value = "view", results = { @Result(name = "success", location = "/client/datapage/dataView.jsp") })
    public String view() throws Exception {
        method = "view";

        if(ri==null){
            rd = new ReportData();
            Map<String, String> indis = new HashMap<String, String>();
            Map<String, RangeObj> ranges = new HashMap<String, RangeObj>();
            rd.setRanges(ranges);
            rd.setIndis(indis);            
        }else{
            ri = (ReportInstance) reportInstanceManager.getObject(ReportInstance.class, ri.getGuid());
            
            Template template = ri.getTemplate();
            templateGuid = template.getGuid();

            if (ri.getStatus() != null) {
                rd = dataOperationManager.getReportData(ri, templateGuid);
            }

            if (rd == null) {
                rd = new ReportData();
                Map<String, String> indis = new HashMap<String, String>();
                Map<String, RangeObj> ranges = new HashMap<String, RangeObj>();
                rd.setRanges(ranges);
                rd.setIndis(indis);
            }

            User user = this.getSessionUser();
            calculator.doCalculate(templateGuid, rd, Formula.EXECUTEPOINT_VIEW, user, ri);
        }        

        return SUCCESS;
    }

    @SuppressWarnings("unchecked")
    @Action(value = "print", results = { @Result(name = "success", location = "/client/datapage/dataPrint.jsp") })
    public String print() throws Exception {
        method = "view";
        ri = (ReportInstance) reportInstanceManager.getObject(ReportInstance.class, ri.getGuid());

        Template template = ri.getTemplate();
        templateGuid = template.getGuid();

        if (ri.getStatus() != null) {
            rd = dataOperationManager.getReportData(ri, templateGuid);
        }

        if (rd == null) {
            rd = new ReportData();
            Map<String, String> indis = new HashMap<String, String>();
            Map<String, RangeObj> ranges = new HashMap<String, RangeObj>();
            rd.setRanges(ranges);
            rd.setIndis(indis);
        }

        User user = this.getSessionUser();
        ri = (ReportInstance) reportInstanceManager.getObject(ReportInstance.class, ri.getGuid());
        calculator.doCalculate(templateGuid, rd, Formula.EXECUTEPOINT_VIEW, user, ri);

        return SUCCESS;
    }

    @SuppressWarnings("unchecked")
    @Action(value = "printBaseInfo", results = { @Result(name = "success", location = "/client/datapage/dataPrint.jsp") })
    public String printBaseInfo() throws Exception {
        if (soi != null) {
            so = (Catalog) catalogManager.getObject(Catalog.class, so.getGuid());
            Template template = so.getTemplate();
            if (template == null) {
                throw new Exception("该基本情况表未和so表进行关联，请咨询管理员");
            }

            templateGuid = template.getGuid();
            String soInstanceGuid = soi.getGuid();
            String tableName = so.getTableName().toLowerCase();

            rd = dataOperationManager.getBaseInfoData(soInstanceGuid, tableName, templateGuid);
        }

        return SUCCESS;
    }

    @Action(value = "remove")
    public String remove() throws Exception {
        LazyDynaBean ldb = new LazyDynaBean();
        try {
            User user = this.getSessionUser();
            dataOperationManager.removeData(node, user);

            ldb.set("success", true);
            ldb.set("reason", "删除成功");
        } catch (Exception e) {
            log.error(ExceptionUtil.transformException(e));
            ldb.set("success", false);
            ldb.set("reason", e.getMessage());
        }

        this.json = JSONObject.fromObject(ldb).toString();
        return AJAX;
    }

    @Action(value = "prepareAddBaseInfo", results = { @Result(name = "success", location = "/client/datapage/dataAddBaseInfo.jsp") })
    public String prepareAddBaseInfo() throws Exception {
        method = "add";
        type = "2"; // 1表示普通报表，2表示基本情况表

        if (selectedTask != null && StringUtils.isNotBlank(selectedTask.getGuid())) {
            selectedTask = (Application) applicationManager.getObject(Application.class, selectedTask.getGuid());
        }

        Catalog catalog = (Catalog) catalogManager.getObject(Catalog.class, so.getGuid());
        service = catalog.getService();

        if (rd == null) {
            rd = new ReportData();
            Map<String, String> indis = new HashMap<String, String>();
            Map<String, RangeObj> ranges = new HashMap<String, RangeObj>();
            rd.setRanges(ranges);
            rd.setIndis(indis);
        }

        so = (Catalog) catalogManager.getObject(Catalog.class, so.getGuid());
        templateGuid = so.getTemplateGuid();
        if (StringUtils.isBlank(templateGuid)) {
            throw new Exception("该基本情况表未和so表进行关联，请咨询管理员");
        }

        calculator.doCalculate(templateGuid, rd, Formula.EXECUTEPOINT_ADD, this.getSessionUser(), null);

        return SUCCESS;
    }

    @Action(value = "prepareEditBaseInfo", results = { @Result(name = "success", location = "/client/datapage/dataEditBaseInfo.jsp") })
    public String prepareEditBaseInfo() throws Exception {
        method = "edit";
        type = "2"; // 1表示普通报表，2表示基本情况表

        if (selectedTask != null && StringUtils.isNotBlank(selectedTask.getGuid())) {
            selectedTask = (Application) applicationManager.getObject(Application.class, selectedTask.getGuid());
        }

        Catalog catalog = (Catalog) catalogManager.getObject(Catalog.class, so.getGuid());
        service = catalog.getService();

        so = (Catalog) catalogManager.getObject(Catalog.class, so.getGuid());
        templateGuid = so.getTemplateGuid();
        if (StringUtils.isBlank(templateGuid)) {
            throw new Exception("该基本情况表未和so表进行关联，请咨询管理员");
        }

        String soInstanceGuid = soi.getGuid();
        String tableName = so.getTableName().toLowerCase();

        rd = dataOperationManager.getBaseInfoData(soInstanceGuid, tableName, templateGuid);

        // 基本情况需要计算公式吗？
        calculator.doCalculate(templateGuid, rd, Formula.EXECUTEPOINT_EDIT, this.getSessionUser(), null);

        return SUCCESS;
    }

    @Action(value = "viewBaseInfo", results = { @Result(name = "success", location = "/client/datapage/dataViewBaseInfo.jsp") })
    public String viewBaseInfo() throws Exception {
        method = "view";

        if (soi != null) {
            so = (Catalog) catalogManager.getObject(Catalog.class, so.getGuid());
            templateGuid = so.getTemplateGuid();
            if (StringUtils.isBlank(templateGuid)) {
                throw new Exception("该基本情况表未和so表进行关联，请咨询管理员");
            }

            String soInstanceGuid = soi.getGuid();
            String tableName = so.getTableName().toLowerCase();

            rd = dataOperationManager.getBaseInfoData(soInstanceGuid, tableName, templateGuid);
        }

        return SUCCESS;
    }

    /*
     * @Action(value="removeBaseInfo", results={
     * 
     * @Result(name="removeBaseInfoError",
     * location="/client/datapage/listSoi.jsp"),
     * 
     * @Result(name="removeBaseInfo",
     * type="redirectAction",params={"namespace","/client/DataQueryAction"
     * ,"actionName","listSoi","selectedTask.guid","${selectedTask.guid}"}) } )
     * public String removeBaseInfo() throws Exception { String result =
     * soInstanceManager.removeSoInstance(soi); log.error(result);
     * if(StringUtils.isNotBlank(result)){ User user = getSessionUser(); sos =
     * this.getUserSOManager().getOffspringSo(selectedTask, user);
     * this.setUserSois
     * (this.getUserSOManager().getSoInstanceByUser(selectedTask, user,
     * soi,null,null)); this.setResultSize(this.getUserSois().size());
     * this.addActionError(result); return "removeBaseInfoError"; }else{ return
     * "removeBaseInfo"; } }
     */

    @Action(value = "prepareDataFileManager", results = { @Result(name = "success", location = "/client/datapage/dataFileManager.jsp") })
    public String prepareDataFileManager() throws Exception {
        return SUCCESS;
    }

    @SuppressWarnings({ "unchecked" })
    @Action(value = "getReportInstanceFiles")
    public String getReportInstanceFiles() throws Exception {
        try {
            List<ReportInstanceFile> fileList = reportInstanceFileManager.find("from ReportInstanceFile t where t.reportInstance.guid='" + this.node + "'");
            this.json = JSONUtil.getJsonString("include", "reportInstanceGuid,guid,name,size", fileList);
        } catch (Exception e) {
            log.error(e);
            this.json = "[]";
        }

        return AJAX;
    }

    @Action(value = "download", results = { @Result(name = "success", type = "stream", params = { "inputName", "fileStream" }) })
    public String download() throws Exception {
        ByteArrayInputStream bais = null;

        try {
            ReportInstanceFile file = (ReportInstanceFile) reportInstanceFileManager.getObject(ReportInstanceFile.class, node);

            byte[] b = file.getContent();

            bais = new ByteArrayInputStream(b);
            this.fileStream = bais;
            this.contentLength = b.length;
            // this.contentType = "application/octet-stream; charset=ISO8859-1";
            this.contentDisposition = "inline; filename=\"" + new String(file.getName().getBytes("GBK"), "ISO8859-1") + "\"";
            // this.contentDisposition = "attachment; filename=\"" + new
            // String(file.getName().getBytes("GBK"), "ISO8859-1") + "\"";
            this.contentType = file.getContentType();
            return SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return SUCCESS;
    }

    @Action(value = "upload", results = { @Result(name = "ajax", type = "ajax", params = { "contentType", "text/html" }) })
    public String upload() throws Exception {
        LazyDynaBean ldb = new LazyDynaBean();
        try {
            if (this.myUpload != null) {
                for (int i = 0; i < this.myUpload.length; i++) {
                    ReportInstanceFile oldFile = (ReportInstanceFile) reportInstanceFileManager.getObject(ReportInstanceFile.class, this.node);
                    if (oldFile == null) {
                        ReportInstance reportInstance = new ReportInstance();
                        reportInstance.setGuid(this.node);

                        oldFile = new ReportInstanceFile();
                        oldFile.setGuid(new GUID().toString());
                        oldFile.setReportInstance(reportInstance);
                    }

                    oldFile.setName(this.myUploadFileName[i]);
                    oldFile.setSize(this.myUpload[i].length());
                    oldFile.setContentType(this.myUploadContentType[i]);
                    oldFile.setContent(FileUtils.readFileToByteArray(this.myUpload[i]));
                    oldFile.setTabIndex(1d);
                    reportInstanceFileManager.saveObject(oldFile);
                }
            }

            ldb.set("success", true);
            ldb.set("reason", "保存成功!");
            this.json = JSONObject.fromObject(ldb).toString();
        } catch (Exception e) {
            ldb.set("success", false);
            ldb.set("reason", e.getMessage());
            this.json = JSONObject.fromObject(ldb).toString();
        }

        return AJAX;
    }

    @Action(value = "removeFile")
    public String removeFile() throws Exception {
        LazyDynaBean ldb = new LazyDynaBean();
        try {
            reportInstanceFileManager.execute("delete from ReportInstanceFile t where t.guid='" + this.node + "'");

            ldb.set("success", true);
            ldb.set("reason", "删除成功!");
            this.json = JSONObject.fromObject(ldb).toString();
        } catch (Exception e) {
            ldb.set("success", false);
            ldb.set("reason", e.getMessage());
            this.json = JSONObject.fromObject(ldb).toString();
            e.printStackTrace();
        }

        return AJAX;
    }
    
    //@Action(value = "refreshJson")
    public String refreshJson()
            throws Exception
        {
            try
            {
                List newList = new ArrayList();
                if("jsonToolTipList".equalsIgnoreCase(whichJson))
                {
                    ri = (ReportInstance)reportInstanceManager.getObject(ReportInstance.class, ri.getGuid());
                    Template template = ri.getTemplate();
                    List list1 = template.getTemplateIndications();
                    for(Iterator iterator = list1.iterator(); iterator.hasNext();)
                    {
                        TemplateIndication ti = (TemplateIndication)iterator.next();
                        String tooltip = ti.getTooltip();
                        if(StringUtils.isNotBlank(tooltip))
                        {
                            HashMap map = new HashMap();
                            map.put("tooltip", tooltip);
                            String range_Name = ti.getRange_Name();
                            if(StringUtils.isBlank(range_Name))
                                map.put("cell", (new StringBuilder("rd.indis['")).append(ti.getAlias_Name()).append("']").toString());
                            else
                                map.put("cell", (new StringBuilder("rd.ranges['")).append(range_Name).append("'].cols['").append(ti.getAlias_ColumnCode()).append("']").toString());
                            newList.add(map);
                        }
                    }

                    json = JSONUtil.getJsonString(null, null, newList, new String[0]);
                }
            }
            catch(Exception e)
            {
                json = "[]";
                e.printStackTrace();
            }
            return "ajax";
        }

    /*
     * (non-Javadoc)
     * 
     * @see
     * net.risesoft.commons.struts2extension.Trimable#afterTrim(com.opensymphony
     * .xwork2.ActionInvocation)
     */
    public void afterTrim(ActionInvocation invocation) {
        // TODO Auto-generated method stub

    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * net.risesoft.commons.struts2extension.Trimable#preTrim(com.opensymphony
     * .xwork2.ActionInvocation)
     */
    public boolean preTrim(ActionInvocation invocation) {
        return true;
    }

    public void setApplicationManager(ApplicationManager applicationManager) {
        this.applicationManager = applicationManager;
    }

    public void setCatalogManager(CatalogManager catalogManager) {
        this.catalogManager = catalogManager;
    }

    public void setReportInstanceManager(ReportInstanceManager reportInstanceManager) {
        this.reportInstanceManager = reportInstanceManager;
    }

    public void setDataOperationManager(DataOperationManager dataOperationManager) {
        this.dataOperationManager = dataOperationManager;
    }

    public void setCalculator(Calculator calculator) {
        this.calculator = calculator;
    }

    public Service getService() {
        return service;
    }

    public void setService(Service service) {
        this.service = service;
    }

    public List<Catalog> getSos() {
        return sos;
    }

    public void setSos(List<Catalog> sos) {
        this.sos = sos;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Catalog getSo() {
        return so;
    }

    public void setSo(Catalog so) {
        this.so = so;
    }

    public List<SoInstance> getUserSois() {
        return userSois;
    }

    public void setUserSois(List<SoInstance> userSois) {
        this.userSois = userSois;
    }

    public Application getSelectedTask() {
        return selectedTask;
    }

    public void setSelectedTask(Application selectedTask) {
        this.selectedTask = selectedTask;
    }

    public SoInstance getSoi() {
        return soi;
    }

    public void setSoi(SoInstance soi) {
        this.soi = soi;
    }

    public String getTemplateGuid() {
        return templateGuid;
    }

    public void setTemplateGuid(String templateGuid) {
        this.templateGuid = templateGuid;
    }

    public ReportInstance getRi() {
        return ri;
    }

    public void setRi(ReportInstance ri) {
        this.ri = ri;
    }

    public ReportData getRd() {
        return rd;
    }

    public void setRd(ReportData rd) {
        this.rd = rd;
    }

    public List<Fault> getContainedFaults() {
        return containedFaults;
    }

    public void setContainedFaults(List<Fault> containedFaults) {
        this.containedFaults = containedFaults;
    }

    public void setMyUpload(File[] myUpload) {
        this.myUpload = myUpload;
    }

    public void setMyUploadFileName(String[] myUploadFileName) {
        this.myUploadFileName = myUploadFileName;
    }

    public void setMyUploadContentType(String[] myUploadContentType) {
        this.myUploadContentType = myUploadContentType;
    }

    public void setFileStream(InputStream fileStream) {
        this.fileStream = fileStream;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public void setContentDisposition(String contentDisposition) {
        this.contentDisposition = contentDisposition;
    }

    public void setContentCharSet(String contentCharSet) {
        this.contentCharSet = contentCharSet;
    }

    public void setBufferSize(int bufferSize) {
        this.bufferSize = bufferSize;
    }

    public void setContentLength(int contentLength) {
        this.contentLength = contentLength;
    }

    public void setAllowCaching(boolean allowCaching) {
        this.allowCaching = allowCaching;
    }

    public void setReportInstanceFileManager(ReportInstanceFileManager reportInstanceFileManager) {
        this.reportInstanceFileManager = reportInstanceFileManager;
    }

    public InputStream getFileStream() {
        return fileStream;
    }

    public File[] getMyUpload() {
        return myUpload;
    }

    public String[] getMyUploadFileName() {
        return myUploadFileName;
    }

    public String[] getMyUploadContentType() {
        return myUploadContentType;
    }

    public String getContentType() {
        return contentType;
    }

    public String getContentDisposition() {
        return contentDisposition;
    }

    public String getContentCharSet() {
        return contentCharSet;
    }

    public int getBufferSize() {
        return bufferSize;
    }

    public int getContentLength() {
        return contentLength;
    }

    public boolean isAllowCaching() {
        return allowCaching;
    }

    public String getClientJsValidationError() {
        return clientJsValidationError;
    }

    public void setClientJsValidationError(String clientJsValidationError) {
        this.clientJsValidationError = clientJsValidationError;
    }

}
